<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>输入框测试</title>
    <style>

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            outline: none;
            font-family: 'Poppins', sans-serif;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #111;
        }

        .container {
            position: relative;
            width: 500px;
            padding: 40px;
            background: #151515;
        }

        .container h2 {
            color: #999;
            margin-bottom: 45px;
        }

        .input-field {
            position: relative;
            height: 40px;
            width: 100%;
        }

        .input-field input[type="text"] {
            position: absolute;
            background: transparent;
            border: none;
            box-shadow: none;
            font-size: 16px;
            color: #fff;
            width: 100%;
        }

        .input-field label {
            position: absolute;
            top: 0;
            left: 0;
            color: #555;
            pointer-events: none;
            display: block;
            transition: 0.5s;
        }

        /*
        说明:
            1. .input-field input[type="text"]:valid + label加上后, 输入内容再点击外界就不会使label的内容降下来了.
        */
        .input-field input[type="text"]:focus + label, .input-field input[type="text"]:valid + label {
            transform: translateY(-35px);
            font-size: 14px;
            color: #fff;
            background: #ff006a;
            padding: 2px 6px;
        }

        .input-field span {
            position: absolute;
            bottom: 0;
            right: 0;
            display: block;
            background: #555;
            width: 100%;
            height: 2px;
        }

        .input-field:before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #00b0ff;
            transform: scaleX(0);
            -webkit-transform: scaleX(0);
            transform-origin: right;
            transition: transform 0.5s ease-in-out;
        }

        .input-field input[type="text"]:focus ~ span:before, .input-field input[type="text"]:valid ~ span:before {
            transform: scaleX(1);
            -webkit-transform: scaleX(1);
            transform-origin: left;
            transition: transform 0.5s ease-in-out;
        }

        .btn {
            margin-top: 20px;
            border: none;
            box-shadow: none;
            padding: 10px 25px;
            background: #333;
            color: #fff;
            font-size: 16px;
            cursor: pointer;
        }

        .btn:hover {
            background: #00bcd4;
        }

    </style>
</head>
<body>
<div class="container">
    <h2>how to create custom input field</h2>
    <form>
        <div class="input-field">
            <input type="text" name="" required="" />
            <label>please enter you full name</label>
            <span></span>
        </div>
        <input type="submit" value="show result" name="" class="btn" />
    </form>
</div>
</body>
</html>